<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link rel="icon" href="favicon.ico" type="image/x-icon"/>
        <title>上传素材管理-微信管理-{$site.BACK_NAME}</title>
        <include file="Public:jscss" />
		<css href="__PUBLIC__/js/poshytip/tip-yellowsimple/tip-yellowsimple.css"/>
		<js href="__PUBLIC__/js/poshytip/poshytip.js"/>
    </head>
    <body>
        <div class="wrap">
            <include file="Public:head" />
            <div class="mainBody">
                <include file="Public:left" />
                <div id="Right">
                    <div class="Item hr">
                        <div class="current">上传素材管理</div>
                    </div>
                    <form action="" method="post" id="quickForm">
                        <b>上传素材：</b>
                        <input type="hidden" name="act" value="add" /> &nbsp;
						类型:
                        <select name="type" id="quickType">
							<option selected="selected" value="image">图片</option>
							<option value="voice">语音</option>
							<option value="video">视频</option>
							<option value="thumb">缩图</option>
							<option value="mpnews">图文</option>
						</select>
						备注
						<input type="text" placeholder="备注下该素材的用途" id="remark" class="input" name="remark" value="" /> &nbsp;
						文件:
						<input type="file" name="file" id="file1" class="input" size="30"/>&nbsp;
                        <button class="btn quickSubmit">上传</button>
                    </form>
                    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tab">
                        <thead>
                            <tr align="center">
                                <td width="5%">ID</td>
                                <td width="15%">备注</td>
								<td width="5%">文件大小</td>
								<td width="5%">类型</td>
                                <td width="20%">路径</td>
                                <td width="5%">media_id</td>
								<td width="10%">上传时间</td>
								<td width="5%">状态</td>
                                <td width="30%">操作</td>
                            </tr>
                        </thead>
                        <tbody>
<php>
$t_day3 = 259200;
$t_now1 = time();
</php>
                            <volist name="list" id="upd">
							<tr cid="{$upd.id}">
								<td align="center">
									<a href="{$upd.path}" target="_blank" alt="点击打开附件" title="点击打开附件">{$upd.id}</a>
									<input type="hidden" name="id" value="{$upd.id}"/>
									<input type="hidden" name="mid" value="{$upd['media_id']}"/>
								</td>
								<td>
									<input type="text" name="yremark" class="input" size="30" value="{$upd.remark}"/>
								</td>
								<td>{:byte_format($upd['size'])}</td>
								<td align="center">
									<switch name="upd.type" >
									<case value="image">图片</case>
									<case value="voice">语音</case>
									<case value="video">视频</case>
									<case value="thumb">缩图</case>
									<case value="news">图文</case>
									<default />
									<span style="color:red;">未知</span>
									</switch>
									<input type="hidden" name="type" value="{$upd.type}"/>
								</td>
								<td align="left">
									<input type="text" name="ypath" class="input" size="50" value="{$upd.path}"/>
								</td>
								<td align="center" class="description" title="{$upd['media_id']}">查看</td>
								<td>{$upd.created_at|date="Y-m-d H:i:s",###}</td>
								<td align="center">
<php>
$t_time = $t_now1 - $upd['created_at'];
if ($t_time > $t_day3){
	echo("<span style='color:red;cursor:pointer;' class='lookBtn'>无效</span>");
}else{
	echo("<span style='color:green;cursor:pointer;' class='lookBtn'>有效</span>");
}
</php>
								</td>
								<td align="center">
									<button class="btn agaBtn">重传</button>
									<button class="btn delBtn">删除</button>
									<button class="btn edtBtn">修改</button>
								</td>
							</tr>
                            </volist>
                        </tbody>
                    </table>
					<div class="viciao">{$page}</div>
                </div>
            </div>
        </div>
        <form action="" method="post" id="opForm">
            <input id="id" type="hidden" name="id" />
            <input id="act" type="hidden" name="act" />
            <input id="remark2" type="hidden" name="remark" />
			<input id="path" type="hidden" name="path" />
        </form>
        <div class="clear"></div>
        <include file="Public:foot" />
    </body>
<script type="text/javascript">
var url_key = "{$tempkey}";
var url_temp = "{$tempurl}";
$(function(){
	//上传
	$(".quickSubmit").click(function(){
		if($("#file1").val()==''){
			$.jBox.tip('上传文件不能为空', 'info');
			return false;
		}
		commonAjaxSubmit("","#quickForm");
		return false;
	});
	//选择图文时跳转到图文添加
	$("#quickType").change(function(){
		if($(this).val()=='mpnews'){
			location.href = "{:U('Weixin/mpnews')}";
			return false;
		}
	});
	//重传
	$(".agaBtn").click(function(){
		var obj=$(this).parents("tr");
		$("#id").val(obj.find("input[name='id']").val());
		$("#act").val('aga');
		$.jBox.confirm(
			'确定重新上传【<b>'+obj.find("input[name='yremark']").val()+'</b>】?<br/>重传后该资源的Media_id将发生改变，请注意！',
			"温馨提示",
			function(v, h, f) {
				if (v == true) {
					commonAjaxSubmit("","#opForm");
				}
			},
			{buttons: {'是': true, '否': false}}
		);
	});
	//修改
	$(".edtBtn").click(function(){
		var obj=$(this).parents("tr");
		$("#id").val(obj.find("input[name='id']").val());
		$("#act").val('edt');
		$("#remark2").val(obj.find("input[name='yremark']").val());
		$("#path").val(obj.find("input[name='ypath']").val());
		//图文则进入编辑
		var t_id = obj.find("input[name='id']").val();
		var t_type = obj.find("input[name='type']").val();
		if(t_type == "news"){
			var url_md = "{:U('Weixin/mpedt', array('id'=>-3.1415926))}";
			location.href = url_md.replace("-3.1415926", t_id);
			return false;
		}
		$.jBox.confirm(
			'确定修改【<b>'+obj.find("input[name='yremark']").val()+'</b>】?<br/>修改后该资源的Media_id将发生改变，请注意！',
			"温馨提示",
			function(v, h, f) {
				if (v == true) {
					commonAjaxSubmit("","#opForm");
				}
			},
			{buttons: {'是': true, '否': false}}
		);
	});
	//删除
	$(".delBtn").click(function(){
		var obj=$(this).parents("tr");
		$("#id").val(obj.find("input[name='id']").val());
		$("#act").val('del');
		$.jBox.confirm(
			'确定删除【<b>'+obj.find("input[name='yremark']").val()+'</b>】?',
			"温馨提示",
			function(v, h, f) {
				if (v == true) {
					commonAjaxSubmit("","#opForm");
				}
			},
			{buttons: {'是': true, '否': false}}
		);
	});
	//查看
	$(".lookBtn").click(function(){
		var obj=$(this).parents("tr");		
		var url = url_temp.replace(url_key, obj.find("input[name='mid']").val());
		window.open(url);
	});
	//显示Media_id
	$('.description').poshytip({className: 'tip-yellowsimple', showTimeout: 0.5,alignX: 'center',offsetY: 0,allowTipHover: true});
});
</script>
</html>